import { reactive } from "vue";
import { defineStore } from 'pinia';

export const useUserStore = defineStore('user', {
    state: () => ({
        // 当前选中的组织ID  
        selectedOrgNode: null,
        userModel: reactive({
            id: '',
            realName: '',
            loginName: '',
            password: '',
            orgId: '',
            orgName: '',
            sex: 0,
            birthday: null,
            isUsed: null,
            addTime: null,
            addUserId: '',
            editTime: null,
            editUserId: '',
            roleIds:[],
            roleNames:[],
        }),
        userRoleModel: reactive({
            id: '',
            foreignId: '',
            roleId: '',
            foreignType: null,
            addTime: null,
            addUserId: '',
        })
    }),
    actions: {
        // 更新当前选中的组织ID  
        setSelectedOrgNode(org) {
            this.selectedOrgNode = org;
        },
        resetUserModel() {
            this.userModel = {
                id: '',
                realName: '',
                loginName: '',
                password: '',
                orgId: '',
                orgName: '',
                sex: 0,
                birthday: null,
                isUsed: null,
                addTime: null,
                addUserId: '',
                editTime: null,
                editUserId: '',
                roleIds:[],
                roleNames:[],
            };
        },
        resetUserRoleModel() {
            this.userRoleModel = {
                id: '',
                foreignId: '',
                roleId: '',
                foreignType: null,
                addTime: null,
                addUserId: '',
            }
        }
    },
    getters: {
        // 获取当前选中组织的名称  
        selectedUserName: () => {

        },
    },
});